<%@tag import="itsm.isperp.control.form.process.WorkflowProcesser"%>
<%@ tag language="java" pageEncoding="UTF-8" description="jqGrid 控件."
	trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ attribute name="readonly" required="false" rtexprvalue="true"
	type="java.lang.Boolean" description="默认false"%>
<c:set var="readonly" value="${readonly eq true?true:false }"></c:set>

<script type="text/javascript">
	function formatAppMessageContent(rowObject) {
		var html;
		html = "<div style='padding:0'><div class='ci-failure-info' style='width:100%;'>";
		html = html + "<table class='comment' style='width:100%'>";

		html = html + "<tr>";
		html = html + "<td class='header' colspan='2'>跟踪人员：" + rowObject.creatorName + "&nbsp;&nbsp跟踪时间：" + rowObject.modifyDate;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>内容：";
		html = html + "</td>";
		html = html + "<td class='tdContent' style='white-space:normal;text-overflow:inherit;overflow:inherit'>" + rowObject.content;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "</table></div></div>";
		//temph="<div style='padding:0'><div class='ci-failure-info'><table class='comment' style='width:100%'><tr><td class='header' colspan='2'>处理人：李四&nbsp;&nbsp处理时间：2015-08-30 11:37</td></tr><tr><td class='tdCaption'>原因分析：</td><td class='tdContent'>ewe</td></tr><tr><td class='tdCaption'>解决办法：</td><td class='tdContent'>wew</td></tr><tr><td class='tdCaption'>处理过程：</td><td class='tdContent'>ewewe</td></tr></table></div></div>";
		return html;
	}
	function formatHandleProcess(rowObject) {
		var html;
		html = "<div style='padding:0'><div class='ci-failure-info' style='width:100%;'>";
		html = html + "<table class='comment' style='width:100%'>";

		html = html + "<tr>";
		html = html + "<td class='header' colspan='2'>处理人：" + rowObject.handlerName + "&nbsp;&nbsp处理时间：" + rowObject.modifyDate;
		html = html + "</td>";
		html = html + "</tr>";
		
		
		html = html + "<tr>";
		html = html + "<td class='tdCaption'>原因分析：";
		html = html + "</td>";
		html = html + "<td class='tdContent' style='white-space:normal;text-overflow:inherit;overflow:inherit'>" + (rowObject.reasonAnalyze==undefined?"":rowObject.reasonAnalyze);
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>对应：";
		html = html + "</td>";
		html = html + "<td class='tdContent' style='white-space:normal;text-overflow:inherit;overflow:inherit'>" + (rowObject.solution==undefined?"":rowObject.solution);
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>对策：";
		html = html + "</td>";
		html = html + "<td class='tdContent' style='white-space:normal;text-overflow:inherit;overflow:inherit'>" + (rowObject.handleProcess==undefined?"":rowObject.handleProcess);
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "</table></div></div>";
		//temph="<div style='padding:0'><div class='ci-failure-info'><table class='comment' style='width:100%'><tr><td class='header' colspan='2'>处理人：李四&nbsp;&nbsp处理时间：2015-08-30 11:37</td></tr><tr><td class='tdCaption'>原因分析：</td><td class='tdContent'>ewe</td></tr><tr><td class='tdCaption'>解决办法：</td><td class='tdContent'>wew</td></tr><tr><td class='tdCaption'>处理过程：</td><td class='tdContent'>ewewe</td></tr></table></div></div>";
		return html;

	}
	function printIncident(id) {
		var tempTitle = "打印事件单";
		var tempUrl = "ReportServer?reportlet=incident/cpt_incident_print.cpt&op=write&incident_id=" + id;
		var options = {
			title : tempTitle,
			contentUrl : tempUrl
		};
		isperp.openDialog(options);
	}
</script>

<div class="box tabbedBox tabbedBoxFixed">
	<div class="header">
		<ul>
			<li class="current"><a href="#basicInfo">事件基本信息</a></li>

		
			<li><a href="#relationProcess">关联流程（<label
					id="relationProcessCount" style="color:red"></label>）</a></li>
			<li><a href="#incidentHandleHistory">历史处理过程（<label
					id="incidentHandleHistoryCount" style="color:red"></label>） </a></li>
			<li><a href="#cusIncidentHistory">申报人历史事件（<label
					id="cusIncidentHistoryCount" style="color:red"></label>）</a></li>
			
			<li><a href="#cusIncidentMessage">相关消息（<label
					id="cusIncidentMessageCount" style="color:red">0</label>）</a></li>
			<li><a href="#relateKnowledge">关联知识（<label
					id="relateKnowledgeCount" style="color:red">0</label>）</a></li>
			
		</ul>
		<h2>&nbsp;</h2>
	</div>
	<div style="padding:0" class="content tabbed">

		<div id="basicInfo">
			<div class="box no-border">
				<div class="header">
					<h3>
						事件编号：${model.code}&nbsp;&nbsp;状态：<span class="important-info">${model.status}</span>
					</h3>
				</div>
				<div
					style="position: absolute;left:350px;z-index: 100;background: #fff;padding:0 5px 5px 0px;top:0">
					<isperp:processRelationTrace businessKey="${model.id }"></isperp:processRelationTrace>
				</div>
			</div>
			<div class="box" style="overflow: hidden">
				<s:eval
					expression="T(itsm.isperp.control.form.process.WorkflowProcesser).renrder(model.processId)"
					var="processerHtml" />
				${processerHtml }
			</div>
			<isperp:slmInfo slmId="${model.slmId }" objectId="${model.id }"></isperp:slmInfo>
			<jsp:doBody />
		</div>
		 
		<div id="relationProcess">
			<isperp:processRelation businessKey="${model.id }" projectIdValue="${model.projectId }"
				readonly="${readonly }" processKey="incidentProcess"
				projectIdControl="projectId" showTotalControl="relationProcessCount"></isperp:processRelation>

		</div>
		<div id="incidentHandleHistory">
			<isperp:grid
				url="incident/incident/listHandleProcess?relationId=${model.id }"
				showSearchbar="false" gridId="incidentHandleProcessGrid2"
				showToolbar="false" rownumbers="false" height="auto"
				cusFormatterActions="false"
				loadComplete=" $('#incidentHandleHistoryCount').text( incidentHandleProcessGrid2.jqGrid.getGridParam('records'));">
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				<isperp:column name="reasonAnalyze" title="reasonAnalyze"
					hidden="true">
				</isperp:column>
				<isperp:column name="situationAnalyze" title="situationAnalyze"
					hidden="true">
				</isperp:column>
				<isperp:column name="solution" title="solution" hidden="true">
				</isperp:column>
				<isperp:column name="handleProcess" title="处理过程"
					isFormatterFun="true"
					formatter="return formatHandleProcess(rowObject);">
				</isperp:column>
				<isperp:column name="handlerName" title="处理人" hidden="true">
				</isperp:column>
				<isperp:column name="modifyDate" title="处理时间" hidden="true">
				</isperp:column>
			</isperp:grid>
		</div>
		<div id="cusIncidentHistory">
			<div class="box no-border">
				<div class="header">
					<h3>申报人历史事件（按时间顺序，抓出其历史的报障记录；根据关键字从历史单中检索，如有匹配则红色显示）</h3>
				</div>
				<isperp:grid
					url="incident/incident/listByCusUser?cusUserId=${model.cusUserId }&all=1"
					showSearchbar="false" gridId="userIncidentHistoryGrid" rowNum="10"
					height="auto" showPager="true"
					ondbClickRowEvent="userIncidentHistoryGrid.view(rowid);"
					showToolbar="false" cusViewUrl="incident/incident/view"
					loadComplete=" $('#cusIncidentHistoryCount').text( userIncidentHistoryGrid.jqGrid.getGridParam('records'));">
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="code" title="事件编号" width="100">
					</isperp:column>
					<isperp:column name="title" title="标题" width="300">
					</isperp:column>
					<isperp:column name="createDate" title="报障时间" width="120">
					</isperp:column>
					<isperp:column name="status" title="处理状态" width="60">
					</isperp:column>
					<isperp:column name="solverName" title="处理人" width="60"
						align="center">
					</isperp:column>
					<isperp:column name="solvedDate" title="解决时间" width="120">
					</isperp:column>
				</isperp:grid>
			</div>
		</div>
		
		<div id="cusIncidentMessage">
			<div class="box no-border">

				<isperp:grid
					url="app/message/listBySourceId?all=1&sourceId=${model.id }"
					showSearchbar="false" gridId="userIncidentMessageGrid"
					cusViewUrl="app/message/view" cusDialogSize="normal"
					showToolbar="true"
					loadComplete=" $('#cusIncidentMessageCount').text( userIncidentMessageGrid.jqGrid.getGridParam('records'));">
					<jsp:attribute name="toolbar">
						<c:if test="${readonly eq false}">
						（备注：消息发送后不会即时显示在列表中）
						  <isperp:button id="userIncidentMessageCreate"
							icon="icon-plus" text="发送消息" cssClass="button  nui-mainbtn"
							onclick="isperp.openDialog({contentUrl:'app/message/sender/sendEdit?sourceId=${model.id }'})"></isperp:button>
						</c:if>
					</jsp:attribute>
					<jsp:body>
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="sender_name" title="发送人" width="80">
						</isperp:column>
						<isperp:column name="receiver_name" title="接收人" width="80">
						</isperp:column>
						<isperp:column name="content" title="内容" width="300">
						</isperp:column>
						<isperp:column name="message_type" title="发送方式" width="70"
							isFormatterFun="true"
							formatter="if('LEAVEMSG'==cellvalue){return '留言';}else{return cellvalue;}">
						</isperp:column>
						<isperp:column name="create_date" title="发送时间" width="110">
						</isperp:column>
				</jsp:body></isperp:grid>
			</div>
		</div>
		
		<div id="relateKnowledge">
			<div class="box no-border">
              <isperp:grid gridId="knowledgeGrid" url="" autowidth="true"
					multiselect="false"
					loadComplete=" $('#relateKnowledgeCount').text( knowledgeGrid.jqGrid.getGridParam('records'));"
					showToolbar="false" cusFormatterActions="false" cusDialogSize="big"
					cusViewUrl="knowledge/knowledgeSearch/knowledgeInfoView"
					ondbClickRowEvent="knowledgeGrid.view(rowid);" rowNum="5"
					showSearchbar="false" autoload="false">
					<isperp:column name="id" title="ID" hidden="true"></isperp:column>
					<isperp:column name="title" width="120" title="标题"></isperp:column>
					<isperp:column name="contents" width="150" title="详细内容"></isperp:column>
				</isperp:grid>
			</div>
		</div>
		
	</div>
</div>


